home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / ainet / ainetdll.h < prev    next >
C/C++ Source or Header  |  1997-07-20  |  10KB  |  216 lines

  1. /* ----------------------------------------------------------------------- *
  2.  *                                                                         *
  3.  *    (C) Copyright 1997 by:  aiNet                                        *
  4.  *                                        Trubarjeva 42                                *
  5.  *                            SI-3000 Celje                                *
  6.  *                                        Slovenia, Europe                             *
  7.  *     All Rights Reserved                                                 *
  8.  *                                                                         *
  9.  *     Subject: Simplified C code for single vector prediction.            *
  10.  *     File:    C header file, 32 bit version                              *
  11.  *                                                                         *
  12.  *     Last revision: 20.7.97                                             *
  13.  *                                                                         *
  14.  * ----------------------------------------------------------------------- */
  15.  
  16. #ifndef AINETDLL_H
  17. #define AINETDLL_H
  18.  
  19. #include <windows.h>
  20.  
  21. #if defined(__cplusplus)
  22.  #define CFN extern "C"
  23. #else
  24.  #define CFN
  25. #endif
  26.  
  27. /*
  28.    Following lines enable that DLL source code sees functions as __export
  29.    and aplication code as __import (which is your case).
  30.    All functions in 32 bit version use __stdcall calling convention.
  31. */
  32.  
  33. /* 32 bit version */
  34. #if defined(__WIN32__)
  35. # if defined(AINETDLL_BLD)
  36. #  define AIDCC __export __stdcall
  37. # else
  38. #  if defined(__BORLANDC__)
  39. #   define AIDCC __import __stdcall
  40. #  else
  41. #   define AIDCC __stdcall
  42. #  endif
  43. # endif
  44. /* 16 bit version */
  45. #else
  46. # if defined(AINETDLL_BLD)
  47. #  define AIDCC FAR PASCAL __export
  48. # else
  49. #   define AIDCC FAR PASCAL
  50. # endif
  51. #endif
  52. /* Constants */
  53. /* ----------------------------------------------------------------------- */
  54.  
  55. /* Error constants */
  56.  
  57. #define AIERR_NO_ERROR           0
  58. #define AIERR_PENALTY_ZERO      -1
  59. #define AIERR_NO_IO_VARIABLES   -2
  60. #define AIERR_PENALTY_TOO_SMALL -3
  61. #define AIERR_EMPTY_ROW         -4
  62. #define AIERR_EMPTY_COLUMN      -5
  63. #define AIERR_EQUAL_COLUMN      -6
  64. #define AIERR_CSV_OPEN          -7
  65. #define AIERR_CSV_READ          -8
  66. #define AIERR_MEMORY_ALLOCATION -9
  67. #define AIERR_INVALID_POINTER   -10
  68. #define AIERR_INVALID_INDEX     -11
  69. #define AIERR_NO_FREE_ENTRY     -12
  70.  
  71. /* Penalty coefficient constants */
  72.  
  73. #define PENALTY_STATIC   0
  74. #define PENALTY_DYNAMIC  1
  75. #define PENALTY_NEAREST  2
  76.  
  77. /* Normalization constants */
  78.  
  79. #define NORMALIZE_REGULAR   0
  80. #define NORMALIZE_STATISTICAL  1
  81.  
  82. /* Definitions */
  83. /* ----------------------------------------------------------------------- */
  84.  
  85. /* The aiVector is simply a pointer to float */
  86.  
  87. typedef float*  aiVector;
  88.  
  89. /* The aiModel Structure */
  90.  
  91. typedef struct aiTagModel{
  92.     float **data;        /* model (vector of model vectors)             */
  93.     int nMV;             /* number of model vectors                     */
  94.     int nVar;            /* total number of variables                   */
  95.     int ni;              /* number of input variables                   */
  96.     int* discrete;            /* array of flags                              */
  97.     aiVector n1;            /* normalization / denormalization             */
  98.     aiVector n2;            /* ...                                         */
  99.     /* Added in version 1.24 */
  100.    int capacity;        /* max num. of MV which can be currenty stored */
  101.    unsigned char* flag; /* indicates if model vector is included or not*/
  102. } aiModel;
  103.  
  104. extern const float MISSING;
  105.  
  106. /* Function prototypes */
  107. /* ----------------------------------------------------------------------- */
  108. #if defined (AI_STATIC_DLL_BINDING)
  109. /*
  110.  * If you want to bind ainetxx.dll statically to your exe (or dll) using
  111.  * ainetxx.lib file, than you must define the AI_STATIC_DLL_BINDING flag
  112.  * before you include ainetdll.h file.
  113.  * It has been reported that ainet16.dll can be easily linked statically
  114.  * with almost any C/C++ compiler.
  115.  *
  116.  * ATTENTION: This is not true with ainet32.dll.
  117.  * ainet32.dll can be statically linked only with Borland C++ 5.0.
  118.  * Any other compiler should load and bind ainet32.dll dynamically.
  119.  */
  120.  
  121. /* Functions defined in DLL */
  122. /* ----------------------------------------------------------------------- */
  123.  
  124. CFN int      AIDCC aiRegistration(const char* user,const char* code);
  125. CFN int      AIDCC aiGetVersion(void);
  126. CFN aiModel* AIDCC aiCreateModel(int nMV, int nVar, int nInputVar);
  127. CFN aiModel* AIDCC aiCreateModelFromCSVFile(const char* fileName);
  128. CFN int      AIDCC aiDeleteModel(aiModel* model);
  129. CFN int      AIDCC aiNormalize(aiModel* model, int method);
  130. CFN int      AIDCC aiDenormalize(aiModel* model);
  131. CFN int      AIDCC aiPrediction(aiModel* model, aiVector toPredict, float penalty, int method);
  132. CFN int      AIDCC aiGetNumberOfVariables(aiModel* model);
  133. CFN int      AIDCC aiGetNumberOfModelVectors(aiModel* model);
  134. CFN int      AIDCC aiGetNumberOfInputVariables(aiModel* model);
  135. CFN int      AIDCC aiSetDiscreteFlag(aiModel* model, int i, BOOL f);
  136. CFN int      AIDCC aiGetDiscreteFlag(aiModel* model, int i);
  137. CFN int      AIDCC aiSetVariable(aiModel* model, int mv, int v, float value);
  138. CFN float    AIDCC aiGetVariable(aiModel* model, int mv, int v);
  139. CFN int      AIDCC aiGetVariableVB(aiModel* model, int mv, int v,float* value);
  140. CFN DWORD    AIDCC aiGetCSVFileModelSize(const char* fileName);
  141. /*NEW FUNCTIONS ->version 1.24*/
  142. CFN int      AIDCC aiSetCapacity(aiModel* model, int newCap);
  143. CFN int      AIDCC aiGetCapacity(aiModel* model);
  144. CFN int      AIDCC aiGetFreeEntries(aiModel* model);
  145. CFN int      AIDCC aiInsertModelVector(aiModel* model, int index, aiVector newMV);
  146. CFN int      AIDCC aiOverwriteModelVector(aiModel* model, int index, aiVector newMV);
  147. CFN int      AIDCC aiAppendModelVector(aiModel* model, aiVector newMV);
  148. CFN int      AIDCC aiDeleteModelVector(aiModel* model, int index);
  149. CFN int      AIDCC aiPredictionEx(aiModel* model, aiVector toPredict, float penalty, int method, int* list, int listSize, BOOL mostInf );
  150. CFN int      AIDCC aiExcludeModelVector(aiModel* model, int i, BOOL exclude);
  151. CFN int      AIDCC aiExcludeModelVectorRange(aiModel* model, int start, int end, BOOL exclude);
  152. CFN BOOL     AIDCC aiIsModelVectorExcluded(aiModel* model, int i);
  153. CFN int      AIDCC aiSaveCSVFile(aiModel* model, const char* fileName);
  154.  
  155.  
  156. /*
  157.  * NOTE: Most of above functions return an integer. If the return value
  158.  * is equal to AIERR_NO_ERROR than the function was succesful.
  159.  * A negative value usually indicates an error.
  160.  */
  161.  
  162. #else /* NO STATIC BINDING - DEFAULT */
  163.  
  164. /* Typedefs functions defined in DLL */
  165. /* ----------------------------------------------------------------------- */
  166. /*
  167.  * Pointers to functions above. Use these definitions when ainetxx.dll is
  168.  * loaded at run tume, which is the default option.
  169.  * To enable these typedefs, the AI_STATIC_DLL_BINDING flag must NOT be defined
  170.  * before ainetdll.h file is included.
  171.  * Please, see examples to find out how to use ainetxx.dll and dynamic linking.
  172.  */
  173. #if defined(__WIN32__)
  174. # define __call __stdcall
  175. #else
  176. #define __call FAR PASCAL
  177. #endif
  178.  
  179. typedef int      (__call *t_aiRegistration)(const char* user,const char* code);
  180. typedef int      (__call *t_aiGetVersion)(void);
  181. typedef aiModel* (__call *t_aiCreateModel)(int nMV, int nVar, int nInputVar);
  182. typedef aiModel* (__call *t_aiCreateModelFromCSVFile)(const char* fileName);
  183. typedef int      (__call *t_aiDeleteModel)(aiModel* model);
  184. typedef int      (__call *t_aiNormalize)(aiModel* model, int method);
  185. typedef int      (__call *t_aiDenormalize)(aiModel* model);
  186. typedef int      (__call *t_aiPrediction)(aiModel* model, aiVector toPredict,
  187.                                               float penalty, int method);
  188. typedef int      (__call *t_aiGetNumberOfVariables)(aiModel* model);
  189. typedef int      (__call *t_aiGetNumberOfModelVectors)(aiModel* model);
  190. typedef int      (__call *t_aiGetNumberOfInputVariables)(aiModel* model);
  191. typedef int      (__call *t_aiSetDiscreteFlag)(aiModel* model, int i, BOOL f);
  192. typedef int      (__call *t_aiGetDi